import idc
import ida_dbg
def get_result(is_64bit):
    if is_64bit:
        res = idc.get_reg_value("RAX")
    else:
        res = idc.get_reg_value("EAX")
    return res

def get_func_args(nth, is_64bit):
    ida_dbg.refresh_debugger_memory()
    if is_64bit:
        four_args = ["RCX", "RDX", "R8", "R9"]
        if nth == 0:
            rsp = idc.get_reg_value("RSP")
            result = idc.get_qword(rsp)
        elif nth < 5:
            result = idc.get_reg_value(four_args[nth - 1])
        else:
            rsp = idc.get_reg_value("RSP")
            result = idc.get_qword(rsp + nth * 8)
    else:
        esp = idc.get_reg_value("ESP")
        result = idc.get_wide_dword(esp + nth * 4)
    return result